package com.hzqx.xxzx.zystudy.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hzqx.xxzx.zystudy.common.security.entity.SelfUserEntity;

import com.hzqx.xxzx.zystudy.common.util.ResultUtil;
import com.hzqx.xxzx.zystudy.common.util.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.hzqx.xxzx.zystudy.core.dao.SysUserDao;
import com.hzqx.xxzx.zystudy.core.entity.SysMenuEntity;
import com.hzqx.xxzx.zystudy.core.entity.SysRoleEntity;
import com.hzqx.xxzx.zystudy.core.service.SysMenuService;
import com.hzqx.xxzx.zystudy.core.service.SysUserService;

@RestController
public class study6_10Controller {
	
	@Autowired
	private SysMenuService menuService;
	@Autowired
	private SysUserService userService;
	
	@PreAuthorize("hasPermission('/get10Data','sys:user:info')")
	@RequestMapping("get10Data")
	public List<SysRoleEntity> getData() {
		List<SysRoleEntity> list = userService.selectSysRoleByUserId(1L);
		return list;
	}
	/**
	 * 管理端信息
	 * @Author Sans
	 * @CreateTime 2019/10/2 14:22
	 * @Return Map<String,Object> 返回数据MAP
	 */
	@PreAuthorize("hasRole('USER')")
	@RequestMapping(value = "/info",method = RequestMethod.GET)
	public Map<String,Object> userLogin(){
		Map<String,Object> result = new HashMap<>();
		SelfUserEntity userDetails = SecurityUtil.getUserInfo();
		result.put("title","管理端信息");
		result.put("data",userDetails);
		return ResultUtil.resultSuccess(result);
	}

}
